Enhancement/11092 refactor reporting key events datapoints#12391
Enhancement/11092 refactor reporting key events datapoints#12391abdelmalekkkkk wants to merge 8 commits intodevelopfrom
Conversation
📦 Build files for 5ab1bf9:
🎭 Playwright reports for 5ab1bf9: |
hussain-t
left a comment
There was a problem hiding this comment.
Thanks, @abdelmalekkkkk! Could you please resolve the conflicts with the latest develop and send it back?
99e0f3f to
bf546b0
Compare
|
@hussain-t Done! Back to you. |
hussain-t
left a comment
There was a problem hiding this comment.
Thanks, @abdelmalekkkkk! Overall, the changes look good. However, I've left a concern and a few minor comments. Please take a look.
| * | ||
| * @var Analytics_4_Report_Response | ||
| */ | ||
| private $reportResponse; |
There was a problem hiding this comment.
Let's use snake_case as per WP standards.
| private $reportResponse; | |
| private $report_response; |
| } | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Please remove the extra blank line.
| */ | ||
| private $analytics; | ||
|
|
||
|
|
There was a problem hiding this comment.
Please remove the extra blank line.
| 'service' => function () use ( $service ) { | ||
| return $service; | ||
| }, | ||
| 'shareable' => true, |
There was a problem hiding this comment.
Get_Report extends Shareable_Datapoint which unconditionally returns true from is_shareable(). Passing 'shareable' => true in the definition is redundant.
| 'shareable' => true, |
|
|
||
| use Google\Site_Kit\Core\REST_API\Data_Request; | ||
| use Google\Site_Kit\Modules\Analytics_4\Datapoints\Get_Key_Events; | ||
| use Google\Site_Kit\Modules\Analytics_4\Report\Response as ReportResponse; |
There was a problem hiding this comment.
Let's remove this unused import.
| use Google\Site_Kit\Modules\Analytics_4\Report\Response as ReportResponse; |
includes/Modules/Analytics_4.php
Outdated
| use Google\Site_Kit\Modules\Analytics_4\Datapoints\Get_Report; | ||
| use Google\Site_Kit\Modules\Analytics_4\Datapoints\Get_Key_Events; | ||
| use Google\Site_Kit\Modules\Analytics_4\Datapoints\Get_Has_Property_Access; |
There was a problem hiding this comment.
A nitpicky one, however, while we are at it, can you reorder these imports and group them with other Get_* imports?
| protected function is_shared_data_request( Data_Request $data ) { | ||
| $datapoint = $this->get_datapoint_definition( "{$data->method}:{$data->datapoint}" ); | ||
| $oauth_client = $this->get_oauth_client_for_datapoint( $datapoint ); | ||
| $datapoint = $this->get_datapoint_definition( "{$data->method}:{$data->datapoint}" ); |
There was a problem hiding this comment.
The refactored is_shared_data_request() no longer accounts for the scope validation fallback in get_oauth_client_for_datapoint().
Previously, if all sharing conditions were met but the owner's scopes failed validation, get_oauth_client_for_datapoint() would fall back to the default client, and is_shared_data_request() would return false (since the clients matched). Now it returns true regardless of scope validation.
This means shared-data restrictions (e.g. date range limits in GET:batch-report, metric/dimension validation in AdSense) could be applied to requests that are actually using the current user's own credentials — potentially restricting data the user should have full access to.
Should this method preserve the old scope-aware behavior?
There was a problem hiding this comment.
Thanks for pointing that out. I thought checking the clients was just a quick way to determine if the request was shared. I reverted some of the changes and only left the new is_shared_datapoint_request. Please take another look.
5168e7c to
1a10f88
Compare
1a10f88 to
5ab1bf9
Compare
|
Thanks @hussain-t. I addressed all your comments. Please take another look. |
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist